package igou.togogo.service.impl;

import igou.togogo.bean.EImg;
import igou.togogo.bean.EImgExample;
import igou.togogo.mapper.EImgMapper;
import igou.togogo.pojo.EgouResult;
import igou.togogo.service.ImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ImgCserviceImpl implements ImgService {

    @Autowired
    EImgMapper imgMapper;

    @Override
    public EgouResult getMainImg(Integer productId) {
        EImgExample example = new EImgExample();
        example.createCriteria().andProductIdEqualTo(productId);
        List<EImg> imgs = imgMapper.selectByExample(example);
        if (!imgs.isEmpty()){
            return EgouResult.ok(imgs.get(0));
        }
        return null;
    }
}
